package com.xc.service.impl;

import com.xc.dto.ResultDTO;
import com.xc.entity.RoleEntity;
import com.xc.mapper.RoleMapper;
import com.xc.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;

    @Override
    public ResultDTO add(RoleEntity roleEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(roleMapper.add(roleEntity))
                .build();
    }

    @Override
    public ResultDTO update(RoleEntity roleEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(roleMapper.update(roleEntity))
                .build();
    }

    @Override
    public ResultDTO delete(RoleEntity roleEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(roleMapper.delete(roleEntity))
                .build();
    }

    @Override
    public ResultDTO updateEnable(RoleEntity roleEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(roleMapper.updateEnable(roleEntity))
                .build();
    }

    @Override
    public ResultDTO findById(RoleEntity roleEntity) {
        return ResultDTO.builder()
                .code(0)
                .data(roleMapper.findById(roleEntity))
                .build();
    }

    @Override
    public ResultDTO findAll(RoleEntity roleEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(roleMapper.count(roleEntity))
                .data(roleMapper.findAll(roleEntity))
                .build();
    }

    @Override
    public ResultDTO count(RoleEntity roleEntity) {
        return ResultDTO.builder()
                .code(0)
                .count(roleMapper.count(roleEntity))
                .build();
    }

    @Override
    public ResultDTO findByName(RoleEntity roleEntity) {
        return null;
    }

    @Override
    public ResultDTO field(RoleEntity roleEntity) {
        return ResultDTO.data(roleMapper.field(roleEntity));
    }
}
